package org.kingkong.framework.resolver.el;

import java.lang.annotation.Annotation;

import javax.el.ELContext;
import javax.el.ELException;

import org.springframework.web.jsf.el.SpringBeanFacesELResolver;

public class CustomBeanFacesELResolver extends SpringBeanFacesELResolver {

	@Override
	public Object getValue(ELContext elContext, Object base, Object property)
			throws ELException {
		if (base instanceof Annotation) {
			final Annotation annotation = (Annotation) base;
			if (annotation != null) {
				try {
					final Object value = annotation.annotationType()
							.getMethod((String) property).invoke(annotation);
					elContext.setPropertyResolved(true);
					return value.toString();
				} catch (final Exception e) {
					e.printStackTrace();
				}
			}
		}
		return super.getValue(elContext, base, property);
	}

}
